package com.examination.controller.statisticsModel;


import com.examination.entity.CountType;
import com.examination.entity.Questions;
import com.examination.entity.TrainContentRecord;
import com.examination.service.checkModel.ExamRecordService;
import com.examination.service.checkModel.ExaminationService;
import com.examination.service.checkModel.QuestionsService;
import com.examination.service.staffModel.StaffService;
import com.examination.service.trainModel.TrainCommonalityService;
import com.examination.service.trainModel.TrainContentRecordService;
import com.examination.service.trainModel.TrainContentService;
import com.examination.service.trainModel.TrainService;
import com.examination.util.CountList;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(description = "PC端统计图数据接口")
@RestController
@RequestMapping("count_PC")
@CrossOrigin
public class PcCountController {
    @Autowired
    private StaffService staffService;

    @Autowired
    private QuestionsService questionsService;

    @Autowired
    private ExaminationService examinationService;

    @Autowired
    private TrainService trainService;

    @Autowired
    private TrainCommonalityService trainCommonalityService;

    @Autowired
    private ExamRecordService examRecordService;

    @Autowired
    private TrainContentRecordService trainContentRecordService;

    @Autowired
    private TrainContentService trainContentService;

    @ApiOperation(value = "App统计数据" , notes = "测试数据:{\"user_id\":2}")
    @PostMapping("/CountApp")
    public CountList CountApp(@RequestBody Map map) {
        CountList countList = new CountList();
        countList.setSj(examinationService.CountAll(map));
        countList.setSt(questionsService.CountAll(map));
        countList.setXy(staffService.CountAll(map));
        countList.setPxkc(trainService.CountAll(map));
        countList.setKcdq(trainCommonalityService.CountAll(map));
        return countList;
    }

    @ApiOperation(value = "试题总数" , notes = "测试数据:{\"user_id\":2}")
    @PostMapping("/CountST")
    public int CountST(@RequestBody Map map) {
        return questionsService.CountAll(map);
    }

    @ApiOperation(value = "试卷总数" , notes = "测试数据:{\"user_id\":2}")
    @PostMapping("/CountSJ")
    public int CountSJ(@RequestBody Map map) {
        return examinationService.CountAll(map);
    }

    @ApiOperation(value = "学员总数" , notes = "测试数据:{\"user_id\":2}")
    @PostMapping("/CountXY")
    public int CountXY(@RequestBody Map map) {
        return staffService.CountAll(map);
    }

    @ApiOperation(value = "培训课程总数" , notes = "测试数据:{\"user_id\":2}")
    @PostMapping("/CountPXKC")
    public int CountPXKC(@RequestBody Map map) {
        return trainService.CountAll(map);
    }

    @ApiOperation(value = "公共课程总数" , notes = "")
    @PostMapping("/CountGGKC")
    public int CountGGKC(@RequestBody Map map) {
        return trainCommonalityService.CountAll(map);
    }

    @ApiOperation(value = "考试合格率" , notes = "测试数据:{\"user_id\":2}")
    @PostMapping("/CountKSHGL")
    public Double CountKSHGL(@RequestBody Map map) {
        double i = examRecordService.CountT(map);
        double l = examRecordService.CountAll(map);
        double s = (i / l) * 100;
        return s;
    }

    @ApiOperation(value = "专业知识分布" , notes = "测试数据:{\"user_id\":2}")
    @PostMapping("/CountByKnowledge")
    public List<Questions> CountByKnowledge(@RequestBody Map map) {
        return questionsService.CountByKnowledge(map);
    }

    @ApiOperation(value = "专业知识分布" , notes = "测试数据:{\"user_id\":2}")
    @PostMapping("/CountBySpecialty")
    public List<Questions> CountBySpecialty(@RequestBody Map map) {
        return questionsService.CountBySpecialty(map);
    }

    @ApiOperation(value = "近一周人员情况" , notes = "测试数据:{\"user_id\":2}")
    @PostMapping("/Count_Week")
    public List<CountType> Count_Week(@RequestBody Map map) {
        return trainContentRecordService.Count_Week(map);
    }

    @ApiOperation(value = "近一个月人员情况" , notes = "测试数据:{\"user_id\":2}")
    @PostMapping("/Count_Month")
    public List<CountType> Count_Month(@RequestBody Map map) {
        return trainContentRecordService.Count_Month(map);
    }

    @ApiOperation(value = "累计培训人数" , notes = "测试数据:{\"user_id\":2}")
    @PostMapping("/Count_all_person")
    public int Count_all_person(@RequestBody Map map) {
        return trainContentRecordService.Count_all(map);
    }

    @ApiOperation(value = "当日培训人数" , notes = "测试数据:{\"user_id\":2}")
    @PostMapping("/Count_day")
    public int Count_day(@RequestBody Map map) {
        return trainContentRecordService.Count_day(map);
    }

    @ApiOperation(value = "项目总数" , notes = "测试数据:{\"user_id\":2}")
    @PostMapping("/Count_all_train")
    public int Count_all_train(@RequestBody Map map) {
        return trainContentService.Count_all(map);
    }

    @ApiOperation(value = "展示当天培训人员信息" , notes = "测试数据:{\"user_id\":2}")
    @PostMapping("/SelectContentRecord")
    public List<TrainContentRecord> SelectContentRecord(@RequestBody Map map) {
        return trainContentRecordService.SelectContentRecord(map);
    }
}
